import utime
from neopixel import NeoPixel
from machine import Pin
from 驱动.ws2812Screen import WS2812Screen
from setting import *
 
from ImgData import *
 
import random

SCREEN_WIDTH = 32  # 屏幕宽
SCREEN_HEIGHT = 8  # 屏幕高

num_leds = SCREEN_WIDTH * SCREEN_HEIGHT  # 像素数量(led灯珠数量)

np = NeoPixel(Pin(5), num_leds + 64)  # 创建像素序列对象

screen = WS2812Screen(np, SCREEN_WIDTH, SCREEN_HEIGHT)  # 创建屏幕对象

print("frank=====================")


#一级菜单循环显示
for i in range(5):
    print("frank=====================")
    print(menu32x8[i])
    
# 流水灯动画
for i in range(8):
     for j in range(32):
         screen.draw_pixel(j, i, (50, 10 + j * 5, 10 + i * 10), 0.5)
         screen.show()


# 清屏
np.fill((0,0,0))
np.write()


# 显示图
screen.draw_img(0, 0, img8x8A,)
screen.show()
utime.sleep(2)


# 清屏
np.fill((0,0,0))
np.write()

# 显示图
screen.draw_img(0, 0, img8x8B,)
screen.show()
utime.sleep(2)


# 清屏
np.fill((0,0,0))
np.write()
# 图片左右移动动画
for zz in range(0,2):
    for x in range(0,24):
        screen.draw_img(x, 0, bilibili9x8[0], 0.1)
        if x > 0:
            for y in range(8):
                screen.draw_pixel(x-1,y,(0,0,0))
        screen.show()

    for x in range(0,24):
        screen.draw_img(32-x-8, 0, bilibili9x8[0], 0.1)
        for y in range(8):
            screen.draw_pixel(32-x-8+8,y,(0,0,0))
        screen.show()

# 清屏
np.fill((0,0,0))
np.write()

# 显示图
for num in range(1,3):
    screen.draw_img(0, 0, bilibili9x8[num],)
    screen.show()
    utime.sleep(2)
# 清屏
    np.fill((0,0,0))
    np.write()

# 显示图
for num in range(0,3):
    screen.draw_img(0, 0, info8x8[num],)
    screen.show()
    utime.sleep(2)
# 清屏
    np.fill((0,0,0))
    np.write()
# 显示图
for num in range(0,1):
    screen.draw_img(0, 0, time_menu11x8[num],)
    screen.show()
    utime.sleep(2)
# 清屏
    np.fill((0,0,0))
    np.write()
    
# 0-10数字显示
for i in range(10):
    print(i)
    screen.draw_num(i*4,1,i,(random.randint(20,200),random.randint(20,200),random.randint(20,200)),1)
    screen.show()
    utime.sleep(0.1)
#     np.fill((0,0,0))
    np.write()

# 清屏
np.fill((0,0,0))
np.write()

#一级菜单循环显示
for i in range(5):
    screen.draw_img(0, 0, menu32x8[i], 0.3)
    screen.show()
    utime.sleep(1)
